import 'dart:math';

import 'package:flutter/material.dart';
import 'package:fucius/Models/talentModel.dart';
import 'package:fucius/widgets/chat/chat.dart';

class TalentDetail extends StatefulWidget {
  TalentDetail(this._talent, this.currentUserId);

  final TalentModel _talent;
  final String currentUserId;

  @override
  _TalentState createState() => _TalentState();
}

class _TalentState extends State<TalentDetail> {
  static Random random = Random();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        padding: EdgeInsets.symmetric(horizontal: 10),
        child: Container(
          width: MediaQuery.of(context).size.width,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              SizedBox(height: 40),
              CircleAvatar(
                backgroundImage: NetworkImage(
                  widget._talent.avatar,
                ),
                radius: 50,
              ),
              SizedBox(height: 10),
              Text(
                widget._talent.name,
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                  fontSize: 22,
                ),
              ),
              SizedBox(height: 3),
              Text(
                widget._talent.major,
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontWeight: FontWeight.normal,
                  fontSize: 15,
                ),
              ),
              SizedBox(height: 20),
              Row(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  FlatButton(
                    child: Icon(
                      Icons.message,
                      color: Colors.white,
                    ),
                    color: Colors.grey,
                    onPressed: () {
                      Navigator.push(
                          context,
                          MaterialPageRoute(
                              builder: (context) => Chat(
                                currentId: widget.currentUserId,
                                peerId: widget._talent.id,
                                peerAvatar: "http://www.ghost64.com/qqtupian/zixunImg/local/2019/03/21/15531703562123.jpeg",
                              )));
                    },
                  ),
                  SizedBox(width: 10),
                  FlatButton(
                    child: Icon(
                      Icons.add,
                      color: Colors.white,
                    ),
                    color: Theme.of(context).accentColor,
                    onPressed: () {},
                  ),
                ],
              ),
//              SizedBox(height: 30),
              new Divider(color: Colors.black,),
              Container(
                  color: Colors.white,
                  child: Padding(
                      padding: EdgeInsets.all(15.0),
                      child: Column(
                        children: <Widget>[
                          Row(
                            children: <Widget>[
                              Container(
                                margin: const EdgeInsets.only(bottom: 10.0),
                                child: Text('Description',
                                    style: TextStyle(fontSize: 20.0, backgroundColor: Colors.grey)),
                              )
                            ],
                          ),
                          RichText(
                              text: TextSpan(
                            text: widget._talent.short_bio,
                            style:
                                TextStyle(fontSize: 14.0, color: Colors.black),
                          ))
                        ],
                      )))
            ],
          ),
        ),
      ),
    );
  }
}
